package com.me.service;

import com.me.pojo.FileMail;
import com.me.pojo.MailInfo;
import com.me.pojo.SimpleMail;
import com.me.service.Mail.MailInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

@Service
public class AsyncTaskInfo {

    @Autowired
    MailInfoService mailInfoService;

    @Async
    public void mailInfo(MailInfo mailInfo) {
        mailInfoService.MailInfo(mailInfo);
    }

    public MailInfo simpleMailInfo(SimpleMail simpleMail) {
        return new MailInfo(simpleMail.getSubject(),simpleMail.getText(),simpleMail.getTo(),simpleMail.getFrom());
    }

    public MailInfo fileMailInfo(FileMail mail) {
        MailInfo mailInfo = new MailInfo(mail.getSubject(),mail.getText(),mail.getTo(),mail.getFrom());
        mailInfo.setFileFlag(1);
        return mailInfo;
    }
}
